<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel="stylesheet" type="text/css" href="../js/themes/default/peasyui.css">
	<link rel="stylesheet" type="text/css" href="../js/themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo/demo.css">
	<link rel="stylesheet" type="text/css" href="../css/dianjia.css"/>
	<script type="text/javascript" src="../js/jquery-1.8.3.min.js"></script>
	<script type="text/javascript" src="../js/template.js"></script>
	<script type="text/javascript" src="../js/jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../js/locale/easyui-lang-zh_CN.js"></script>
	<script type="text/javascript" src="../js/plugins/jquery.datagrid.js"></script>
	<script type="text/javascript">		
	
	$(function(){
		$(".sercapacity3").hide();
		$(".searchButton").click(function(){
			$(".sercapacity3").hide();
			$(this).next(".sercapacity3").show();
		 })
		 $(".sercapacity3 input.djque").click(function(){
		  $(this).parent(".sercapacity3").hide();
		
		})
	});
	
		
		$(function(){
			$("#pageCount").val($('#pageSize option:selected').val());
		})
		
		function currentPageToOne(){	
			currPage=1;	
			$("#currentPage").text(currPage);
			$("#currPage").val(currPage);
	
		}	
		
		
		function fenye(mark){

			 currPage = Number($("#currPage").val());	
		     totalPages = Number($("#totalPages").val());
			if(mark=="previous"){
				if(currPage==1){	
					alert("已经是首页了！");
				}else{				
					currPage = currPage-1;
					$("#currPage").val(currPage);
					$("#currentPage").text(currPage);
				
				}
			}else if(mark=="next"){
				if(currPage>=totalPages){	
					alert("没有下一页！");
					$("#next").attr("disabled",true);
				}else{
					currPage = currPage+1;
					$("#currPage").val(currPage);
					$("#currentPage").text(currPage);
				
				}			
			}
		}
		
		
		function getCd(){
			
			
			$.ajax({
				type:"GET",
		 		async: false,
				url:'<%=path%>/main/get/subject',
				dateType:'json',
				data:{"pageSize":$("#pageSize").val(),"pageNum":$("#currPage").val()},
				success:function(data){
				var result = eval('(' + data + ')');	
				
				var num=result.data.length;
				if(num!=0){
					$("#totalPages").val(result.total);
			    	$("#ltotalPages").text(result.total);
				}else{
					$("#ltotalPages").val(1);
				}
				
				
				var beans = {			
						list : result.data
		      		};
				var html = template('memberList', beans);
				console.log(beans);
				document.getElementById('memberNames').innerHTML =html;
					}
				});
		}
		
		
		
		
		$(document).ready(function(){
			$("#btn2").click(function(){
		
				var sj=$("input[name=memNamecheckbox]:checked").parent().parent().children(1).text();
				
				$.ajax({
					type:"POST",
			 		async: false,
					url:'<%=path%>/main/get/subjectInfo',
					dateType:'json',
					data:{"code":sj},
					success:function(data){
						var result = eval('(' + data + ')');	
											
						}
					});
			});
			
	});
	</script>
	
	<script>
	

	
	
	
	
	function selectOne(dd){
		var memberCheck = $(".memberCheck");
		$.each(memberCheck,function(i,n){
			if(dd ==  n){}
			else{
				n.checked=false;
			}
		});
	}
	</script>
<style>
.search { position:relative; width: 147px; }
	#d1{
		text-align:center;
	}

#d2{
	width: 800px;
	margin: 45px auto;
	margin-top: 40px;
}
#btn2{
	margin-left: -200px;
}
#sercapacity3{
	margin-left: 176px;
	margin-top: -46px;
	height: 375px;
}
#d2 table{border-right:1px solid black;border-bottom:1px solid black;} 
#d2 table td{border-left:1px solid black;border-top:1px solid black;width: 100px;
  		  height: 28px;text-align: center;} 
</style>
<title>Insert title here</title>
</head>
<body>
		<div id="d1"><h2>应收应付配置表</h2></div>
		<div id="d2">
			<table  width="800px" id="billtable">
				
				<tr><td></td><td>序号</td><td>类型(其他应收应付)</td>
				
				<td>
					<div class="search">
						
							科目编码<input id="btn1" class="searchButton" type="button" value="搜索" onclick="getCd()"/>
						<div class="sercapacity3" id="sercapacity3">
							<input type="button" id="btn2" value="确认" class="inconsbtns djque"/>
								<div class="uldiv">
									<table cellpadding="0" cellspacing="0" style="width: 100%">
										<tr class="first">
											<td width="18%">选框</td>
											<td>编码</td>
										</tr>
										<tbody id="memberNames">
											<script type="text/html" id="memberList" name="memberList">
                   							{{each list as value index}}
												<tr>
													<td><input type="checkbox"  value={{value.code}} name="memNamecheckbox" id="checkbox" class="memberCheck" onclick="selectOne(this)"></td>
													<td><input type="hidden" value={{value.code}} name="memName" id="memName"/>{{value.code}}</td>				
												</tr>
											{{/each}}
                    	   				</script>
										</tbody>
										<tr>
											<input name = "currPage" id ="currPage" value="1" type="hidden">
											<input name = "totalPages" id ="totalPages" value="" type="hidden">
											<input name = "pageCount" id ="pageCount" value="" type="hidden">										
																				
											<td colspan="3">
												第 <span><label id="currentPage" >1</label></span> 页
												<span id="s2"><a href="#gotop" id="previous" onclick="fenye('previous')">上一页</a></span>
												<span id="s3"><a href="#gotop" id="next" onclick="fenye('next')">下一页</a></span>
												共<span><label id="ltotalPages"></label></span>页
												
													<select id="pageSize" name="store" onchange="currentPageToOne();">
														<option value="6" >6</option>	
														<option value="7" >7</option>	
														<option value="8" >8</option>	
														<option value="9" >9</option>	
														<option value="10" >10</option>																
													</select>
												
											</td>
										</tr>
									</table>
								</div>
						</div>
						</div>
				</td>
				
				<td>科目名称</td><td></td></tr>	
				
				
				
				
                		
			</table>
		</div>
</body>
</html>